package com.easy.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easy.common.bean.SysRole;
import com.easy.common.bean.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<SysUser> {

    @Delete("delete from sys_user_role where user_id=#{userid}")
    int deleteUserRoleByUserId(@Param("userid") Integer userid);


   @Insert("insert into sys_user_role value (#{userid)")
   int insertUserRole(@Param("userid")Integer userid,@Param("roleid") Integer roleid);

    @Select("select * from sys_user where username=#{username}")
    SysUser getOneByUsername(@Param("username") String username);
    @Select("select * from sys_role where id in (select role_id from sys_user_role where user_id=#{id})")
    List<SysRole> getRolesByUserID(@Param("id")Integer userid);
}
